﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMIS_ERP.Web.Head_User
{
    public partial class Modify_Self : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    string huID = Request.Params["id"];
                    ShowInfo(huID);
                }
            }

        }
        /// <summary>
        /// 显示用户信息
        /// </summary>
        /// <param name="huID">用户ID</param>
        private void ShowInfo(string huID)
        {
            IMIS_ERP.BLL.Head_User bll = new IMIS_ERP.BLL.Head_User();
            IMIS_ERP.Model.Head_User model = bll.GetModel(huID);
            this.lblhuID.Text = model.huID;
            this.txthuType.DataSource = new string[] { "财务人员", "业务人员", "经理" };
            this.txthuType.DataBind();
            this.txthuType.SelectedIndex = Convert.ToInt32(model.huType);
            this.txthuName.Text = model.huName;
            this.txthuPwd.Text = model.huPwd;
            this.txthuPhone.Text = model.huPhone;
            this.txthuInfo.Text = model.huInfo;

        }
        /// <summary>
        /// 保存按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnSave_Click(object sender, EventArgs e)
        {


            IMIS_ERP.Model.Head_User model = new IMIS_ERP.Model.Head_User();
            model.huID = this.lblhuID.Text.Trim();
            model.huType = this.txthuType.SelectedIndex.ToString();
            model.huName = this.txthuName.Text;
            model.huPwd = this.txthuPwd.Text;
            model.huPhone = this.txthuPhone.Text;
            model.huInfo = this.txthuInfo.Text;

            IMIS_ERP.BLL.Head_User bll = new IMIS_ERP.BLL.Head_User();
            if (bll.Update(model))
            {

               
            }
            else
            {
                lblMessage.Text = "修改信息失败,请重试";
            }

        }


    }
}